<%@ taglib prefix="g" uri="/web-app/WEB-INF/tld/grails.tld" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Create Task</title>         
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><g:link class="list" action="list">Task List</g:link></span>
        </div>
        <div class="body">
            <h1>Create Task for ${fieldValue(bean:user, field:'firstname')}</h1>
          
            <g:hasErrors bean="${task}">
	            <div id="errors">
	                <g:renderErrors bean="${task}" as="list" />
	            </div>
            </g:hasErrors>
          
            <g:form action="save" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="name">Name:</label>
                                </td>
                                <td valign="top" class="prop ${hasErrors(bean:task,field:'name','errors')}">
                                    <input type="text" maxlength="50" id="name" name="name" value="${fieldValue(bean:task,field:'name')}"/>
                                </td>
                            </tr> 

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description">Description:</label>
                                </td>
                                <td valign="top" class="prop ${hasErrors(bean:task,field:'description','errors')}">
                                    <input type="text" id="description" name="description" value="${fieldValue(bean:task,field:'description')}"/>
                                </td>
                            </tr> 
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description">When:</label>
                                </td>
                                <td valign="top" class="prop ${hasErrors(bean:task, field:'date', 'errors')}">
                                    <g:datePicker name="date" value="${new Date().plus(1)}" precision="minute" years="[2009]"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="priority">Priority:</label>
                                </td>
                                <td valign="top" class="prop ${hasErrors(bean:task, field:'priority', 'errors')}">
                                    <g:select optionKey="id" from="${Priority.list()}" name="priority.id" value="${task?.priority?.id}">
                                    </g:select>
                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><input class="save" type="submit" value="Create" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
